const db = wx.cloud.database()
const _ = db.command
Page({
  data: {
    res: {},
    id: '',
    swiperList: [],
    zbList:[]
  },
  todetail(e){
    console.log(e)
    var id=e.currentTarget.dataset.index
    wx.navigateTo({
      url: '../placedetail/placedetail?id='+id,
    })
  },
  getzb() {
    // 这个函数用来get周边的景点
    var id=this.data.id
    var list=[id+'']
    console.log(list)
    db.collection('placeList')

      .limit(5)
      .get().then(res=>{
        console.log('返回来的周边景点',res)
        this.setData({
          zbList:res.data.reverse()
        })
      })
 
  },
  onLoad(e) {
    wx.showLoading({
      title: '正在加载',
    })
    var id = e.id
    this.setData({
      id,
    })
    this.getzb()
    console.log(id)
    wx.cloud.callFunction({
      name: 'getplacebyid',
      data: {
        id,
      }
    }).then(res => {
      console.log(res)
      this.setData({
        res: res.result.data
      })
      wx.setNavigationBarTitle({
        title: res.result.data.name,
      })
      wx.hideLoading()
    })
  }
})